package com.community.web.controller.suggest;

import java.util.List;

import com.community.body.domain.ZyComplaintSuggest;
import com.community.body.dto.ComplaintSuggestDTO;
import com.community.body.service.IZyComplaintSuggestService;
import com.community.body.vo.EchartsVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.community.common.annotation.Log;
import com.community.common.core.controller.BaseController;
import com.community.common.core.domain.AjaxResult;
import com.community.common.enums.BusinessType;
import com.community.common.core.page.TableDataInfo;

/**
 * 投诉建议 Controller
 * 
 * @author community
 * @date 2024-04-16
 */
@RestController
@RequestMapping("/suggest/complaint")
public class ZyComplaintSuggestController extends BaseController
{
    @Autowired
    private IZyComplaintSuggestService zyComplaintSuggestService;

    /**
     * 查询投诉建议 列表
     */
    @PreAuthorize("@ss.hasPermi('suggest:complaint:list')")
    @GetMapping("/list")
    public TableDataInfo list(ComplaintSuggestDTO complaintSuggestDTO)
    {
        startPage();
        List<ComplaintSuggestDTO> list = zyComplaintSuggestService.selectZyComplaintSuggestList(complaintSuggestDTO);
        return getDataTable(list);
    }

    @GetMapping("/statusList")
    public TableDataInfo getStatusList(ComplaintSuggestDTO complaintSuggestDTO)
    {
        List<EchartsVo> list = zyComplaintSuggestService.getStatusList(complaintSuggestDTO);
        return getDataTable(list);
    }

    /**
     * 导出投诉建议 列表
     */
//    @PreAuthorize("@ss.hasPermi('suggest:complaint:export')")
//    @Log(title = "投诉建议 ", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ZyComplaintSuggest zyComplaintSuggest)
//    {
//        List<ComplaintSuggestDTO> list = zyComplaintSuggestService.selectZyComplaintSuggestList(zyComplaintSuggest);
//        ExcelUtil<ZyComplaintSuggest> util = new ExcelUtil<ZyComplaintSuggest>(ZyComplaintSuggest.class);
//        util.exportExcel(response, list, "投诉建议 数据");
//    }

    /**
     * 获取投诉建议 详细信息
     */
    @PreAuthorize("@ss.hasPermi('suggest:complaint:query')")
    @GetMapping(value = "/{complaintSuggestId}")
    public AjaxResult getInfo(@PathVariable("complaintSuggestId") Long complaintSuggestId)
    {
        return success(zyComplaintSuggestService.selectZyComplaintSuggestByComplaintSuggestId(complaintSuggestId));
    }

    /**
     * 新增投诉建议 
     */
    @PreAuthorize("@ss.hasPermi('suggest:complaint:add')")
    @Log(title = "投诉建议 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZyComplaintSuggest zyComplaintSuggest)
    {
        return toAjax(zyComplaintSuggestService.insertZyComplaintSuggest(zyComplaintSuggest));
    }

    /**
     * 修改投诉建议 
     */
    @PreAuthorize("@ss.hasPermi('suggest:complaint:edit')")
    @Log(title = "投诉建议 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZyComplaintSuggest zyComplaintSuggest)
    {
        return toAjax(zyComplaintSuggestService.updateZyComplaintSuggest(zyComplaintSuggest));
    }

    /**
     * 删除投诉建议 
     */
    @PreAuthorize("@ss.hasPermi('suggest:complaint:remove')")
    @Log(title = "投诉建议 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{complaintSuggestIds}")
    public AjaxResult remove(@PathVariable Long[] complaintSuggestIds)
    {
        return toAjax(zyComplaintSuggestService.deleteZyComplaintSuggestByComplaintSuggestIds(complaintSuggestIds));
    }
}
